package cn.caijiapeng.spt.kit;

import com.alibaba.fastjson.JSONObject;
import com.jfinal.kit.HttpKit;

import cn.caijiapeng.spt.bean.Operate;

public class LocationKit {
	public static Operate<JSONObject> getLocationByIp(String ip) {
		String url = "http://ip.taobao.com/service/getIpInfo.php?ip=" + ip;
		try {
			JSONObject result = JSONObject.parseObject(HttpKit.get(url));
			if(result.getInteger("code") == 0) {
				return Operate.ok(result);
			}
		} catch (Exception e) {			
		}
		return Operate.fail();
	}
}
